package TAIC.util;

import java.io.File;
import java.io.PrintStream;
import java.util.Scanner;


/**
 * 
 * @author yuqiangchen
 * This program makes indexes for all the pictures under the voc256 directory
 */

public class MakeIndexes {
	static public void main ( String [] para ){
		if ( para.length != 1 ) {
			System.out.println ( "please input the config file that contains the folder names") ;
		}
		try{
			Scanner scanner = new Scanner ( new File ( para[ 0 ] )) ; 
			while ( scanner.hasNext() ) {
				String dirName = scanner.next () ;
				File dir = new File ( dirName + "\\" ) ;
				File [] allFiles = dir.listFiles() ;
				PrintStream fout = new PrintStream ( new File ( dirName + "\\index.txt" )) ;
				for ( File f : allFiles ) 
					if ( f.getName().endsWith(".png") || f.getName().endsWith(".jpg")) fout.println ( f.getName() );
				fout.close() ;
			}
		}
		catch ( Exception e ){
			e.printStackTrace() ;
		}
	}
}
